<?php

require_once(dm::getDir().'/dmFrontPlugin/lib/config/dmFrontApplicationConfiguration.php');

class frontConfiguration extends dmFrontApplicationConfiguration
{
  public function configure()
  {
  // this will listen to contact saving and call listenToContactSavedEvent method  
        $this->dispatcher->connect('dm_contact.saved', array($this, 'listenToContactSavedEvent'));  
  }
  public function listenToContactSavedEvent(sfEvent $e)  
    {  
        // get the contact object passed by the event  
        $contact = $e['contact'];  
        // get the service container from the context  
        $serviceContainer = $e->getSubject()->getServiceContainer();  
        // get a mail service instance  
        $mailService = $serviceContainer->getService('mail');  
        // use our DmMailTemplate  
        $mailService->setTemplate('email_contact_form');  
        // add values to populate the template  
        $mailService->addValues(array(  
                                'created_at' => $contact->created_at,  
                                'name'       => $contact->name,  
                                'email'      => $contact->email,  
                                'content'    => $contact->body  
                            ));  
        // send the mail using Swift Mailer  
       
        // $sent = $mailService->send();  
    }  
}